import React, { useState } from 'react';
import MusicItem from './musicItem'

import axios from 'axios'

const Music = () => {
    const [playlists] = useState(playlists)
    React.useEffect(() => {
        console.log('组件初始化调用一次');
        axios
            .get(`http://122.112.161.135:3000/top/playlist?cat=华语`)
            .then(res => {
                // this.setState({ playlists: res.data.playlists })
                playlists = res.data.playlists
            })
    }, [])
    return (
        <div>
            <MusicItem playlists={playlists}></MusicItem>
        </div>
    );
}

export default Music;
